#include<bits/stdc++.h>
using namespace std;
int n,l,r,ma=0;
int main(){
	//freopen("candy.in","r",stdin);
	//freopen("candy.out","w",stdout);
	cin>>n;
	cin>>l>>r;
	for(int i=l;i<=r;i++){
		int j=i%n;
		ma=max(ma,j);
	}
	cout<<ma;
	//fclose(stdin);
	//fclose(stdout);
return 0;
}
